package com.principal.action;



	import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.List;

	import javax.servlet.http.HttpServletRequest;
	import javax.servlet.http.HttpServletResponse;
	import org.apache.struts.action.Action;
	import org.apache.struts.action.ActionForm;
	import org.apache.struts.action.ActionForward;
	import org.apache.struts.action.ActionMapping;
	import org.hibernate.Query;
	import org.hibernate.Session;

	import com.nexxoft.struts.connection.Connec;
	import com.pojos.ReplacePersons;
import com.principal.form.ReplacePersonsForm;

	/** 
	 * MyEclipse Struts
	 * Creation date: 06-28-2012
	 * 
	 * XDoclet definition:
	 * @struts.action path="/ViewHODdetails" name="replace" scope="request" validate="true"
	 * @struts.action-forward name="showhoddetails" path="/ViewHodDetails.jsp"
	 */
	public class HodViewProblemAction  extends Action {
		/*
		 * Generated Methods
		 */

		/** 
		 * Method execute
		 * @param mapping
		 * @param form
		 * @param request
		 * @param response
		 * @return ActionForward
		 */
		public ActionForward execute(ActionMapping mapping, ActionForm form,
				HttpServletRequest request, HttpServletResponse response) {
			// TODO Auto-generated method stub
			java.util.Date utilDate = new java.util.Date();
		    java.sql.Date sqlDate = new java.sql.Date(utilDate.getTime());
		    System.out.println("utilDate:" + utilDate);
		    System.out.println("sqlDate:" + sqlDate);
		    Calendar cal=Calendar.getInstance();
		   cal.add(Calendar.DATE,-5);
		  
		   java.util.Date d1=cal.getTime(); 
		   SimpleDateFormat sdf=new SimpleDateFormat("dd-MMM-yyyy");
		   String dat=sdf.format(d1);
		   System.out.println(dat);
		//   java.sql.Date endDate = new java.sql.Date(d1.getTime());
		 
			Session session=Connec.getSession();
			Query qry;
			qry=session.createQuery("from AddProblems p where p.status='Under Procesing' and p.date1<=to_date('"+dat+"')");
			List problemslist=qry.list();
			request.setAttribute("probdetails", problemslist);
			session.close();
			return mapping.findForward("showproblems");
			
		}
	}